"use strict";
const e = require("../../common/vendor.js"),
  a = require("../../api/request.js"),
  u = require("../../api/MenuButton.js"),
  t = {
    __name: "login",
    setup(t) {
      e.useCssVars((a => ({
        "4b74c490": e.unref(u.MenuButton)().top,
        "764435e4": e.unref(u.MenuButton)().height
      })));
      const s = e.ref(""),
        l = e.ref(""),
        r = e.ref(""),
        n = e.ref(!1),
        o = e.ref(!1),
        v = e.ref(60),
        i = e.ref("发送验证码"),
        c = e.ref("");
      async function d() {
        const e = await a.requestApi("/vercode", {
          phoneNumbers: s.value
        });
        c.value = e.data.bizId, o.value = !0;
        var u = setInterval((() => {
          v.value > 1 ? (v.value--, i.value = `${v.value}秒后重新获取`) : (clearInterval(u), o.value = !1, v.value = 60, i.value = "发送验证码")
        }), 1e3)
      }
      async function f() {
        if (e.wx$1.showLoading({
            title: "登陆中",
            mask: !0
          }), n.value) {
          const u = await a.requestApi("/mobile_registration", {
            mobile: s.value,
            code: r.value,
            bizId: c.value
          }, "POST");
          e.wx$1.setStorageSync("userInfor", u.data)
        } else {
          const u = await a.requestApi("/login", {
            mobile: s.value,
            password: l.value
          }, "POST");
          e.wx$1.setStorageSync("userInfor", u.data)
        }
        e.index.$emit("loginSuccess", !0), e.wx$1.navigateBack({
          delta: 1
        })
      }

      function g() {
        e.wx$1.navigateTo({
          url: "/pages/password-settings/password"
        })
      }

      function p() {
        e.index.navigateBack({
          delta: 1
        })
      }
      return (a, u) => e.e({
        a: e.o(p),
        b: e.s(a.__cssVars()),
        c: e.s(a.__cssVars()),
        d: s.value,
        e: e.o((e => s.value = e.detail.value)),
        f: !n.value
      }, n.value ? {} : {
        g: l.value,
        h: e.o((e => l.value = e.detail.value))
      }, {
        i: n.value
      }, n.value ? {
        j: r.value,
        k: e.o((e => r.value = e.detail.value)),
        l: e.t(i.value),
        m: o.value,
        n: e.o(d)
      } : {}, {
        o: e.o(f),
        p: e.t(n.value ? "账号登陆" : "验证码登陆"),
        q: e.o((e => n.value = !n.value)),
        r: e.o(g),
        s: e.s(a.__cssVars())
      })
    }
  };
wx.createPage(t);